package com.xydtech.ecard.merchant.controller;

import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.domain.entity.SysDept;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.ShiroUtils;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.merchant.domain.EcardAgricultureOvertimeNotVisit;
import com.xydtech.ecard.merchant.service.IEcardOverTimeNotVisitService;
import com.xydtech.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 网点新型农业主体统计超时未拜访明细Controller
 *
 * @author yuzhiguo
 * @date 2024-09-11 下午2:04
 */
@Controller
@RequestMapping("/merchant/branchAgriculture/agrOvertimeNotVisit")
public class EcardAgricultureOverTimeNotVisitController extends BaseController {
    @Autowired
    private IEcardOverTimeNotVisitService ecardOverTimeNotVisitService;
    @Autowired
    private ISysDeptService sysDeptService;

    private String prefix = "merchant";

    //@RequiresPermissions("merchant:entOvertimeNotVisit:view")
    @GetMapping("/{deptId}")
    public String visit(@PathVariable("deptId") String deptId, ModelMap mmap)
    {
        mmap.put("deptId", deptId);
        return prefix + "/agricultureOvertimeNotVisit";
    }

    /**
     * 查询网点新型农业主体统计超时未拜访明细列表
     * @param ecardAgricultureOvertimeNotVisit
     * @return
     */
    //@RequiresPermissions("merchant:agrOvertimeNotVisit:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardAgricultureOvertimeNotVisit ecardAgricultureOvertimeNotVisit) {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        ecardAgricultureOvertimeNotVisit.setDictDeptId(sysDept.getDeptId());
        startPage();
        List<EcardAgricultureOvertimeNotVisit> list = ecardOverTimeNotVisitService.selectAgrOvertimeNotVisit(ecardAgricultureOvertimeNotVisit);
        return getDataTable(list);
    }

    //@RequiresPermissions("merchant:agrOvertimeNotVisit:export")
    @Log(title = "导出网点新型农业主体统计超时未拜访明细列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardAgricultureOvertimeNotVisit ecardAgricultureOvertimeNotVisit)
    {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        ecardAgricultureOvertimeNotVisit.setDictDeptId(sysDept.getDeptId());
        List<EcardAgricultureOvertimeNotVisit> list = ecardOverTimeNotVisitService.selectAgrOvertimeNotVisit(ecardAgricultureOvertimeNotVisit);
        ExcelUtil<EcardAgricultureOvertimeNotVisit> util = new ExcelUtil<EcardAgricultureOvertimeNotVisit>(EcardAgricultureOvertimeNotVisit.class);
        return util.exportExcel(list, "超时未拜访明细信息");
    }
}
